<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html>
<head>
<%@include file="/WEB-INF/jspf/meta/meta.jspf"%>
<title>管理员后台</title>
<%@include file="/WEB-INF/jspf/adminPage.jspf"%>
<script type="text/javascript" src="<%=request.getContextPath() %>/static/_AdminCenter.js"></script>
<script type="text/javascript" src="<%=request.getContextPath() %>/static/_framework/jquery/jquery.serializejson.js"></script>
</head>
<style>
	html,body{padding: 0px;margin: 0px; overflow: hidden; border: 0;width: 100%;height: 100%}
</style>
<script type="text/javascript">
	$(function() {
		$("#tt").tabs({
			onContextMenu : function(e, title, index) {
				e.preventDefault();
				$("#indexMainTabRClickMenu").menu('show', {
					left : e.pageX,
					top : e.pageY
				});
				$("#tabsRClickDoSaveValueID").val(title);
			}
		});

		$.ajax({
			type: "get",
			url: path_home+"/sysPower/readMenu",
			dataType:'json',
			success: function(data){
				let _data = trans(data)
				$('#menu').sidemenu({
					data:_data,
					onSelect:function (node) {
						if (node.file){
							addTab(node.name, node.file);
						}
					},
				})
			}
		});
		$('#updatePassDlg').dialog({
			title: '密码修改',
			width: 400,
			modal: true,
			closed:true,
			buttons: [{
				text:'确定',
				iconCls:'icon-ok',
				handler:function(){
					let isValid = $("#updatePassForm").form('validate');
					if (isValid) {
						let newPwd = $("#newPassword").val();
						let rePwd = $("#reNewPassword").val();
						if (newPwd!=rePwd) {
							$.messager.alert("提示","两次输入的密码不一致","info");
							return ;
						}else{
							var formData = $('#updatePassForm').serializeJSON();
							$.ajax({
								url: path_home+'/user/updatePassword.json',
								data: formData,
								dataType: 'json',
								type: 'post',
								success: function (data) {
									//返回的数据
									$.messager.show({
										title: '提示',
										msg: data.msg,
										timeout: 3000,
										showType: 'slide'
									});
									if (data.code > 0) {
										//成功则关闭对话框
										$('#updatePassDlg').dialog('close');
										$('#updatePassForm').form('clear');
									}
								}
							});
						}
					}else{
						$.messager.alert("提示","请输入正确的数据","info")
					}
				}
			},{
				text:'取消',
				iconCls:'icon-cancel',
				handler:function(){
					$('#updatePassDlg').dialog('close');
				}
			}]
		});



		// $('#userInfoStudent').dialog({
		// 	width:500,
		// 	title:'My Panel'
		// });
		// $('#userInfoTeacher').dialog({
		// 	width:600,
		// 	title:'个人信息'
		// });
	})

	function trans(data) {
		if (data.length>0){
			data.forEach(function (n,i) {
				n['text'] = n['name']
				if (n['children']!=undefined){
					trans(n['children'])
				}
			})
		}
		return data;
	}

	function changePwd() {
		$('#updatePassDlg').dialog("open")
	}

	function showUserInfo() {
		$.ajax({
			url: path_home+'/user/getInfo.json',
			dataType: 'json',
			type: 'get',
			success: function (data) {
				console.log(data)
			}
		});
	}
</script>
<style>
	#userInfoStudent{
		display: flex;
		flex-wrap: wrap;
		justify-content: center;
		align-items: center;
		font-size: 20px;
	}
	#userInfoStudent .info,.value{
		padding: 20px;
		width: 25%;
		border-bottom: 1px solid gainsboro;
		border-left: 1px solid gainsboro;
		box-sizing: border-box;
	}
	#userInfoStudent .info{
		text-align: right;
	}


	#userInfoTeacher{
		display: flex;
		flex-wrap: wrap;
		justify-content: center;
		align-items: center;
		font-size: 20px;
	}
	#userInfoTeacher .info,.value{
		padding: 10px;
		width: 25%;
		border-bottom: 1px solid gainsboro;
		border-left: 1px solid gainsboro;
		box-sizing: border-box;
	}
	#userInfoTeacher .info{
		text-align: right;
	}
</style>
</head>
<body class="easyui-layout" style="margin: 0;">
	<input type="hidden" id="tabsRClickDoSaveValueID" />
	<div data-options="region:'west',split:true" title="菜单" style="width: 15%">
		<div id="menu" style="width: 100%;">
		</div>
	</div>
	<div data-options="region:'center'" style="overflow: hidden;padding: 0px; border: 0 ">
		<div class="easyui-layout" data-options="fit:true">
			<%--更新密码--%>
			<div id="updatePassDlg">
				<div class="easyui-panel"  style="padding:30px	;">
					<form id="updatePassForm" method="post">
						<div style="margin-bottom:20px">
							<input class="easyui-passwordbox" id="oldPassword" name="oldPassword" style="width:100%" data-options="label:'旧密码:',required:true">
						</div>
						<div style="margin-bottom:20px">
							<input class="easyui-passwordbox" id="newPassword" name="newPassword" style="width:100%" data-options="label:'新密码:',required:true" >
						</div>
						<div style="margin-bottom:20px">
							<input class="easyui-passwordbox" id="reNewPassword" name="reNewPassword" style="width:100%" data-options="label:'确认密码:',required:true">
						</div>
					</form>
				</div>
			</div>

				<%--<div id="userInfoStudent">--%>
					<%--<div class="info">学生编号:</div><div class="value"></div>--%>
					<%--<div class="info">学生名称:</div><div class="value">123</div>--%>
					<%--<div class="info">学生账号:</div><div class="value">123</div>--%>
					<%--<div class="info">学生性别:</div><div class="value">123</div>--%>
					<%--<div class="info">学生邮件:</div><div class="value">123</div>--%>
					<%--<div class="info">学生手机号:</div><div class="value">123</div>--%>
					<%--<div class="info">学生生日:</div><div class="value">123</div>--%>
					<%--<div class="info">学生地址:</div><div class="value">123</div>--%>
					<%--<div class="info">学生班级:</div><div class="value">123</div>--%>
					<%--<div class="info">学生科目:</div><div class="value">123</div>--%>
					<%--<div class="info">学生宿舍:</div><div class="value">123</div>--%>
					<%--<div class="info">入学时间:</div><div class="value">123</div>--%>
				<%--</div>--%>
				<%--<div id="userInfoTeacher">--%>
					<%--<div class="info">教师编号:</div><div class="value" id="teacherId">123</div>--%>
					<%--<div class="info">教师名称:</div><div class="value" id="teacherName">123</div>--%>
					<%--<div class="info">教师生日:</div><div class="value" id="teacherBirthday">123</div>--%>
					<%--<div class="info">教师电话:</div><div class="value" id="teacherPhone">123</div>--%>
					<%--<div class="info">教师地址:</div><div class="value" id="teacherAddr">123</div>--%>
					<%--<div class="info">教师性别:</div><div class="value" id="teacherSex">123</div>--%>
					<%--<div class="info">教师邮箱:</div><div class="value" id="teacherEmail">123</div>--%>
					<%--<div class="info">教师账号:</div><div class="value" id="teacherAccount">123</div>--%>
				<%--</div>--%>

			<div class="easyui-tabs" id="tt" fit="true">
				<div title="数据区域"
					 style="padding: 0px 0">
					<img src="<%=request.getContextPath() %>/static/_framework/welcome.png" width="100%" height="98%" alt="">
				</div>
			</div>
		</div>
	</div>
	<%--个人信息菜单--%>
	<div data-options="region:'north',split:true" style="height: 45px; overflow: hidden; text-align: center;">
		<div style="margin-top: 4px;" >
			<div style="float: right;width: 150px" class="easyui-menubutton" data-options="menu:'#linkMenu',iconCls:'icon-search'">
				欢迎你&nbsp;${username}
			</div>
			<div  id="linkMenu" style="width: 50px">
					<%--<div style="color: black" data-options="iconCls:'icon-search'" onclick="showUserInfo()">--%>
						<%--我的信息--%>
					<%--</div>--%>
					<div style="color: black" onclick="changePwd()" data-options="iconCls:'icon-edit'">
						修改密码
					</div>
					<div data-options="iconCls:'icon-undo'">
						<a href="<%=request.getContextPath() %>/login/loginOut"  style="text-decoration: none;color: black"  >退出登陆</a>
					</div>
			</div>
		</div>
	</div>

	<!-- 以下为tabs右击事件 -->
	<div id="indexMainTabRClickMenu" class="easyui-menu"
		style="width: 120px;">
		<div onclick="javascript:index_main_tab_close1()">闭关当前页面</div>
		<div onclick="javascript:index_main_tab_close_other()">关闭其他页面</div>
		<div onclick="javascript:index_main_tab_close()">关闭全部页面</div>
		<div onclick="javascript:index_main_tab_reflash()">刷新</div>
	</div>
</body>
</html>